/* eslint-disable class-methods-use-this */
import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Member {
  async getCostList(page, limit, info) {
    const res = await get(`v1/cost?page=${page}&limit=${limit}`, info)
    return res
  }

  async getMemberList(page, limit, info) {
    const res = await get(`v1/member?page=${page}&limit=${limit}`, info)
    return res
  }

  async getUserList(page, limit, info) {
    const res = await get(`v1/user?page=${page}&limit=${limit}`, info)
    return res
  }

  async getUserMoneyList(page, limit, info) {
    const res = await get(`v1/user/money?page=${page}&limit=${limit}`, info)
    return res
  }

  async getMoneyList(page, limit, info) {
    const res = await get(`v1/member/money?page=${page}&limit=${limit}`, info)
    return res
  }

  async updateMember(info) {
    const res = await put('v1/member', info)
    return res
  }

  async updateUser(info) {
    const res = await put('v1/user', info)
    return res
  }

  async updateMemberGrade(info) {
    const res = await put('v1/member/grade', info)
    return res
  }

  async getCostInfo(id) {
    const res = await get(`v1/cost/${id}`)
    return res
  }

  async createCost(info) {
    const res = await post('v1/cost', info)
    return res
  }

  async updateCost(info) {
    const res = await put('v1/cost', info)
    return res
  }

  async deleteCost(id) {
    const res = await _delete(`v1/cost/${id}`)
    return res
  }
}

export default new Member()
